--
-- Description: 获取商品key数量，决定能否扣减库存
-- param: 1.商品key 2.扣减数量
-- return: boolean
--
local key = KEYS[1]
local minusCount = tonumber(ARGV[1])

local remainCount = tonumber(redis.call("get", key))

if (remainCount >= minusCount) then
    redis.call("set",key,remainCount-minusCount)
    return true;
end

return false;
